<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.20"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libxlsxwriter: hide_row_col.c</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="customdoxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">libxlsxwriter
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.20 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">hide_row_col.c</div>  </div>
</div><!--header-->
<div class="contents">
<table width="600">
<tr>
<td><a class="el" href="comments2_8c-example.html">&lt;&lt; comments2.c</a> </td><td align="right"><a class="el" href="panes_8c-example.html">panes.c &gt;&gt;</a>  </td></tr>
</table>
<p>Example of hiding rows and columns in an Excel worksheet.</p>
<div class="image">
<img src="hide_row_col.png" alt=""/>
</div>
<div class="fragment"><div class="line"><span class="comment">/*</span></div>
<div class="line"><span class="comment"> * An example of how to hide rows and columns using the libxlsxwriter</span></div>
<div class="line"><span class="comment"> * library.</span></div>
<div class="line"><span class="comment"> *</span></div>
<div class="line"><span class="comment"> * In order to hide rows without setting each one, (of approximately 1 million</span></div>
<div class="line"><span class="comment"> * rows), Excel uses an optimization to hide all rows that don&#39;t have data. In</span></div>
<div class="line"><span class="comment"> * Libxlsxwriter we replicate that using the worksheet_set_default_row()</span></div>
<div class="line"><span class="comment"> * function.</span></div>
<div class="line"><span class="comment"> *</span></div>
<div class="line"><span class="comment"> * Copyright 2014-2018, John McNamara, jmcnamara@cpan.org</span></div>
<div class="line"><span class="comment"> *</span></div>
<div class="line"><span class="comment"> */</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &quot;xlsxwriter.h&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Create a new workbook and add a worksheet. */</span></div>
<div class="line">    <a name="_a0"></a><a class="code" href="structlxw__workbook.html">lxw_workbook</a>  *workbook  = <a name="a1"></a><a class="code" href="workbook_8h.html#a1cf96608a23ee4eb0e8467c15240d00b">workbook_new</a>(<span class="stringliteral">&quot;hide_row_col.xlsx&quot;</span>);</div>
<div class="line">    <a name="_a2"></a><a class="code" href="structlxw__worksheet.html">lxw_worksheet</a> *worksheet = <a name="a3"></a><a class="code" href="workbook_8h.html#a81d456b4f65a464e78e4a0030ecc3c2e">workbook_add_worksheet</a>(workbook, NULL);</div>
<div class="line">    <a class="code" href="common_8h.html#aaf33b4e2179dcc466359277210774ce3">lxw_row_t</a> row;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Write some data. */</span></div>
<div class="line">    <a name="a4"></a><a class="code" href="worksheet_8h.html#ac208046e7a6d12cc87982422efa41b31">worksheet_write_string</a>(worksheet, 0, 3, <span class="stringliteral">&quot;Some hidden columns.&quot;</span>, NULL);</div>
<div class="line">    <a class="code" href="worksheet_8h.html#ac208046e7a6d12cc87982422efa41b31">worksheet_write_string</a>(worksheet, 7, 0, <span class="stringliteral">&quot;Some hidden rows.&quot;</span>,    NULL);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Hide all rows without data. */</span></div>
<div class="line">    <a name="a5"></a><a class="code" href="worksheet_8h.html#a74121de7c4f67639b30f302d4af48eb4">worksheet_set_default_row</a>(worksheet, 15, <a name="a6"></a><a class="code" href="common_8h.html#a57bffaf0ff3cb4e9f4f7f2b0b6dad349a7850bcc34c18efe2e45372f4069be0bf">LXW_TRUE</a>);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Set the height of empty rows that we want to display even if it is */</span></div>
<div class="line">    <span class="comment">/* the default height. */</span></div>
<div class="line">    <span class="keywordflow">for</span> (row = 1; row &lt;= 6; row++)</div>
<div class="line">        <a name="a7"></a><a class="code" href="worksheet_8h.html#ab9b7fb95e1bd9b0da70befd0d37a9173">worksheet_set_row</a>(worksheet, row, 15, NULL);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Columns can be hidden explicitly. This doesn&#39;t increase the file size. */</span></div>
<div class="line">    <a name="_a8"></a><a class="code" href="structlxw__row__col__options.html">lxw_row_col_options</a> options = {.<a name="a9"></a><a class="code" href="structlxw__row__col__options.html#a0e46063d954292f4018ecb91621b7562">hidden</a> = 1};</div>
<div class="line">    <a name="a10"></a><a class="code" href="worksheet_8h.html#a52c4c145f684c5b4dcd2ed304d1fe907">worksheet_set_column_opt</a>(worksheet, <a name="a11"></a><a class="code" href="utility_8h.html#a189672bfa9c380a28d8db8c40de17fe8">COLS</a>(<span class="stringliteral">&quot;G:XFD&quot;</span>), 8.43, NULL, &amp;options);</div>
<div class="line"> </div>
<div class="line">    <a name="a12"></a><a class="code" href="workbook_8h.html#ad9e7aeebc0fd43562db5bcd527b2ee5e">workbook_close</a>(workbook);</div>
<div class="line"> </div>
<div class="line">    <span class="keywordflow">return</span> 0;</div>
<div class="line">}</div>
</div><!-- fragment --> </div><!-- contents -->
<div class="ttc" id="astructlxw__row__col__options_html"><div class="ttname"><a href="structlxw__row__col__options.html">lxw_row_col_options</a></div><div class="ttdoc">Options for rows and columns.</div><div class="ttdef"><b>Definition:</b> worksheet.h:716</div></div>
<div class="ttc" id="aworksheet_8h_html_a74121de7c4f67639b30f302d4af48eb4"><div class="ttname"><a href="worksheet_8h.html#a74121de7c4f67639b30f302d4af48eb4">worksheet_set_default_row</a></div><div class="ttdeci">void worksheet_set_default_row(lxw_worksheet *worksheet, double height, uint8_t hide_unused_rows)</div><div class="ttdoc">Set the default row properties.</div></div>
<div class="ttc" id="aworkbook_8h_html_ad9e7aeebc0fd43562db5bcd527b2ee5e"><div class="ttname"><a href="workbook_8h.html#ad9e7aeebc0fd43562db5bcd527b2ee5e">workbook_close</a></div><div class="ttdeci">lxw_error workbook_close(lxw_workbook *workbook)</div><div class="ttdoc">Close the Workbook object and write the XLSX file.</div></div>
<div class="ttc" id="aworkbook_8h_html_a1cf96608a23ee4eb0e8467c15240d00b"><div class="ttname"><a href="workbook_8h.html#a1cf96608a23ee4eb0e8467c15240d00b">workbook_new</a></div><div class="ttdeci">lxw_workbook * workbook_new(const char *filename)</div><div class="ttdoc">Create a new workbook object.</div></div>
<div class="ttc" id="astructlxw__worksheet_html"><div class="ttname"><a href="structlxw__worksheet.html">lxw_worksheet</a></div><div class="ttdoc">Struct to represent an Excel worksheet.</div><div class="ttdef"><b>Definition:</b> worksheet.h:1603</div></div>
<div class="ttc" id="acommon_8h_html_a57bffaf0ff3cb4e9f4f7f2b0b6dad349a7850bcc34c18efe2e45372f4069be0bf"><div class="ttname"><a href="common_8h.html#a57bffaf0ff3cb4e9f4f7f2b0b6dad349a7850bcc34c18efe2e45372f4069be0bf">LXW_TRUE</a></div><div class="ttdeci">@ LXW_TRUE</div><div class="ttdef"><b>Definition:</b> common.h:53</div></div>
<div class="ttc" id="autility_8h_html_a189672bfa9c380a28d8db8c40de17fe8"><div class="ttname"><a href="utility_8h.html#a189672bfa9c380a28d8db8c40de17fe8">COLS</a></div><div class="ttdeci">#define COLS(cols)</div><div class="ttdoc">Convert an Excel A:B column range into a (col1, col2) pair.</div><div class="ttdef"><b>Definition:</b> utility.h:63</div></div>
<div class="ttc" id="aworksheet_8h_html_a52c4c145f684c5b4dcd2ed304d1fe907"><div class="ttname"><a href="worksheet_8h.html#a52c4c145f684c5b4dcd2ed304d1fe907">worksheet_set_column_opt</a></div><div class="ttdeci">lxw_error worksheet_set_column_opt(lxw_worksheet *worksheet, lxw_col_t first_col, lxw_col_t last_col, double width, lxw_format *format, lxw_row_col_options *options)</div><div class="ttdoc">Set the properties for one or more columns of cells with options.</div></div>
<div class="ttc" id="astructlxw__row__col__options_html_a0e46063d954292f4018ecb91621b7562"><div class="ttname"><a href="structlxw__row__col__options.html#a0e46063d954292f4018ecb91621b7562">lxw_row_col_options::hidden</a></div><div class="ttdeci">uint8_t hidden</div><div class="ttdef"><b>Definition:</b> worksheet.h:718</div></div>
<div class="ttc" id="astructlxw__workbook_html"><div class="ttname"><a href="structlxw__workbook.html">lxw_workbook</a></div><div class="ttdoc">Struct to represent an Excel workbook.</div><div class="ttdef"><b>Definition:</b> workbook.h:273</div></div>
<div class="ttc" id="acommon_8h_html_aaf33b4e2179dcc466359277210774ce3"><div class="ttname"><a href="common_8h.html#aaf33b4e2179dcc466359277210774ce3">lxw_row_t</a></div><div class="ttdeci">uint32_t lxw_row_t</div><div class="ttdef"><b>Definition:</b> common.h:40</div></div>
<div class="ttc" id="aworksheet_8h_html_ac208046e7a6d12cc87982422efa41b31"><div class="ttname"><a href="worksheet_8h.html#ac208046e7a6d12cc87982422efa41b31">worksheet_write_string</a></div><div class="ttdeci">lxw_error worksheet_write_string(lxw_worksheet *worksheet, lxw_row_t row, lxw_col_t col, const char *string, lxw_format *format)</div><div class="ttdoc">Write a string to a worksheet cell.</div></div>
<div class="ttc" id="aworksheet_8h_html_ab9b7fb95e1bd9b0da70befd0d37a9173"><div class="ttname"><a href="worksheet_8h.html#ab9b7fb95e1bd9b0da70befd0d37a9173">worksheet_set_row</a></div><div class="ttdeci">lxw_error worksheet_set_row(lxw_worksheet *worksheet, lxw_row_t row, double height, lxw_format *format)</div><div class="ttdoc">Set the properties for a row of cells.</div></div>
<div class="ttc" id="aworkbook_8h_html_a81d456b4f65a464e78e4a0030ecc3c2e"><div class="ttname"><a href="workbook_8h.html#a81d456b4f65a464e78e4a0030ecc3c2e">workbook_add_worksheet</a></div><div class="ttdeci">lxw_worksheet * workbook_add_worksheet(lxw_workbook *workbook, const char *sheetname)</div><div class="ttdoc">Add a new worksheet to a workbook.</div></div>
<!-- HTML footer for doxygen 1.8.20-->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Copyright 2014-2020 John McNamara.
Generated by&#160;<a href="http://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.8.20
</small></address>
</body>
</html>
